package com.jjb.saas.demo.app.role.service.impl;

import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.demo.app.role.executor.command.RoleAddExe;
import com.jjb.saas.demo.app.role.executor.command.RoleUpateExe;
import com.jjb.saas.demo.app.role.executor.query.RoleQueryExe;
import com.jjb.saas.demo.app.role.service.RoleService;
import com.jjb.saas.system.client.role.request.RoleAddCmd;
import com.jjb.saas.system.client.role.request.RolePageQry;
import com.jjb.saas.system.client.role.request.RoleUpdateCmd;
import com.jjb.saas.system.client.role.response.RoleCO;
import com.jjb.saas.system.client.role.response.RoleDetailCO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author tzh * @date 2022年07月08日 18:50
 */
@AllArgsConstructor
@Service
public class RoleServiceImpl implements RoleService {
    private final RoleAddExe roleAddExe;
    private final RoleUpateExe roleUpateExe;
    private final RoleQueryExe roleQueryExe;

    @Override
    public Response add(RoleAddCmd cmd) {
        return roleAddExe.execute(cmd);
    }

    @Override
    public Response update(RoleUpdateCmd cmd) {
        return roleUpateExe.execute(cmd);
    }

    @Override
    public Response updateStatus(Long id, String statusEnum, Integer version) {
        return roleUpateExe.execute(id, statusEnum, version);
    }

    @Override
    public PageResponse<RoleCO> listPage(RolePageQry qry) {
        return roleQueryExe.execute(qry);
    }

    @Override
    public SingleResponse<RoleDetailCO> getDetail(Long id) {
        return roleQueryExe.execute(id);
    }
}
